package examples;

import java.net.InetSocketAddress;

import cn.twinkling.ipc.NetUtils;
import cn.twinkling.ipc.RPC;

public class MultipleClients implements Runnable {
	String name;

	MultipleClients(String name) {
		this.name = name;
	}

	@Override
	public void run() {
		try {
			int port = InstancedServer.PORT;
			String host = NetUtils.getLocalAddress();
			InetSocketAddress addr = NetUtils.makeSocketAddr(host, port);
			Echo proxy = RPC.getProxy(Echo.class, addr);
			System.out.println(name + " Echo.who: " + proxy.who());
			proxy.from("jakkkkkkki");

			ICode proxyCode = RPC.getProxy(ICode.class, addr);
			Code v = proxyCode.generate("bbbbbbbbbbbbbbb");
			System.out.println(name + " ICode.generate: " + v.getLink().length());
		} catch (Throwable e) {
			e.printStackTrace();
		}
	}

}
